home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d996.lha / Startup-Menu / Source / LSKExtras.PAS < prev    next >
Pascal/Delphi Source File  |  1994-04-05  |  4KB  |  191 lines

  1. UNIT LSKExtras;
  2.  
  3. INTERFACE
  4.  
  5. USES Intuition, Graphics, Exec, Gadtools, Utility;
  6.  
  7. Procedure ErrorExit(InitMsg, Errortxt : string);
  8.  
  9. Function RetrieveStr(p : pointer) : string;
  10.  
  11. Procedure DisableGadget(g : pGadget; w : pWindow; Disable : byte);
  12.  
  13. function CStrConstPtr(s : string) : pointer;
  14.  
  15. Function LockFrontPubScr(VAR Screen  : pScreen) : String;
  16.  
  17. Procedure UnlockFrontPubScr(pubname : string; Screendef : pScreen);
  18.  
  19. Procedure DisableWindow(w : pWindow; req : pRequester;  waitpointer : pointer);
  20.  
  21. Procedure EnableWindow(w : pWindow; req : pRequester; IDCMP : LONG);
  22.  
  23. IMPLEMENTATION
  24.  
  25. Procedure ErrorExit;
  26.  
  27. VAR
  28.     ReqIT   : array [1..2] of tIntuiText;
  29.     ReqOk   : tIntuiText;
  30.     ReqStrs : array[1..3] of string;
  31.     z : integer;
  32.     OKRes : boolean;
  33.  
  34. begin
  35.     ReqStrs[1] := InitMsg;
  36.     ReqStrs[2] := Errortxt;
  37.     ReqStrs[3] := 'Exit'#0;
  38.     for z := 1 to 2 do begin
  39.         with ReqIT[z] do begin
  40.           FrontPen  := 0;
  41.           BackPen   := 1;
  42.           DrawMode  := JAM1;
  43.           LeftEdge  := 1;
  44.           TopEdge   := (10 * z);
  45.           ITextFont := NIL;
  46.           IText     := @ReqStrs[z,1];
  47.           if z < 2 then NextText  := @ReqIT[z+1] else NextText := NIL;
  48.         end;
  49.    end;
  50.     with ReqOk do begin
  51.         FrontPen  := 0;
  52.         BackPen   := 1;
  53.         DrawMode  := JAM1;
  54.         LeftEdge  := 2;
  55.         TopEdge   := 2;
  56.         ITextFont := NIL;
  57.         IText     := @ReqStrs[3,1];
  58.         NextText  := NIL
  59.       end;
  60.     OKRes := AutoRequest(NIL, @ReqIT[1], NIL, @ReqOk, 0, 0, IntuiTextLength(@ReqIT[2]) + 40, 80);
  61.                                                                         { sizes needed by v34 }
  62. end;
  63.  
  64. Function RetrieveStr;
  65. Type
  66.   a = Packed Array [0..255] Of Char;     { fills a string with the }
  67. Var                                      { contents of the string  }
  68.   i    : Integer;                        { pointed at              }
  69.   sptr : ^a;                             { (from HSPC init.unit)   }
  70.   s    : string;
  71. Begin
  72.   sptr := p;
  73.   s := '';
  74.   i := 0;
  75.   While sptr^[i] <> #0 Do Begin
  76.     s := s + sptr^[i];
  77.     inc(i)
  78.   End;
  79.   RetrieveStr := s
  80. End;
  81.  
  82. Procedure DisableGadget;
  83.  
  84. VAR Dis_Tags : array[0..1] of tTagItem;
  85.  
  86. begin
  87.     Dis_Tags[0].ti_Tag  := GA_Disabled;
  88.     Dis_Tags[0].ti_Data := Disable;
  89.     Dis_Tags[1].ti_Tag  := TAG_END;
  90.     GT_SetGadgetAttrsA(g,w,NIL,@Dis_Tags);
  91. end;
  92.  
  93. function CStrConstPtr;
  94. type a = packed array [0..255] of char;
  95. var  p : ^a;
  96. begin
  97.   s := s + #0;                         { Make "C" string }
  98.   getmem(p, length(s));                { Get some mem for it }
  99.   move(s[1], p^, length(s));           { Move s into newly alloc'd mem }
  100.   CStrConstPtr := p                    { Return the pointer }
  101. end;
  102.  
  103.  
  104.  
  105.  
  106. Function LockFrontPubScr;
  107. VAR
  108.     LockKey     : Longint;
  109.     My_Node     : pPubScreenNode;
  110.     PS_List     : pList;
  111.      
  112. CONST
  113.     name : string = 'error';
  114.  
  115. begin
  116.     LockKey := LockIBase(0);
  117.     screen := IntuitionBase^.ActiveScreen;
  118.     PS_List := LockPubScreenList;
  119.     My_Node := pPubScreenNode(PS_List^.lh_Head);
  120.     While My_Node^.psn_Node.ln_Succ <> NIL Do Begin
  121.         If my_Node^.psn_Screen = screen Then
  122.             Name := retrievestr(My_Node^.psn_Node.ln_Name);
  123.         My_Node := pPubScreenNode(My_Node^.psn_Node.ln_Succ);
  124.     End;
  125.     UnLockPubScreenList;
  126.     UnlockIBase(LockKey);
  127.     If name = 'error' Then Begin
  128.         screen := lockPubScreen(NIL);
  129.         LockFrontPubScr := '***LSK FPS ERROR';
  130.        If screen = NIL Then begin
  131.            ErrorExit('** LSK Pub Screen broker Failure **','Failed to lock public screen'#0);
  132.            halt(0);
  133.        end; 
  134.    End Else Begin
  135.         name := name + #0;
  136.        screen := lockPubScreen(@Name[1]);
  137.        LockFrontPubScr := name; 
  138.        If screen = NIL Then begin
  139.             ErrorExit('** LSK Pub Screen broker Failure **','Failed to lock public screen'#0);
  140.             halt(0);
  141.         end;
  142.     End;
  143.     
  144. end;
  145.  
  146.  
  147.  
  148. Procedure UnlockFrontPubScr;
  149.  
  150. begin
  151.     If pubname = '***LSK FPS ERROR' Then begin
  152.        UnlockPubScreen(NIL, screendef);
  153.    end Else begin
  154.         UnlockPubScreen(@PubName[1], screendef);
  155.     end;
  156. end;
  157.  
  158. Procedure DisableWindow;
  159.  
  160. VAR result : boolean;
  161.  
  162. begin
  163.     result := ModifyIDCMP(w,IDCMP_REFRESHWINDOW);
  164.     (* Block window input *)
  165.     result := Request(req,w);
  166.     (* Set wait pointer *)
  167.      (*if (OSV39)
  168.      *    SetWindowPointer(w,WA_BusyPointer,TRUE,TAG_DONE);
  169.      * else
  170.      * not yet, only got v37 defines *)
  171.     SetPointer(w,WaitPointer,16,16,-6,0);
  172. end;
  173.  
  174.  
  175. Procedure EnableWindow;
  176.  
  177. VAR result : boolean;
  178.  
  179. begin
  180.     (* if (OSV39)
  181.      *  SetWindowPointer(w,TAG_DONE);
  182.     * else
  183.     * not yet, only got v37 defines *)
  184.     ClearPointer(w);
  185.     (* Enable window input *)
  186.     EndRequest(req,w);
  187.     (* Enable IDCMP *)
  188.     result := ModifyIDCMP(w,idcmp);
  189. end;
  190.  
  191. end.